#pragma GCC optimize(2, "Ofast", "inline")
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <algorithm>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;
const int MOD = 998244353;
const int MXN = 2e5 + 5;
int n;
int a[100005];
int x, tmp;

bool find(int x)
{
    for (int i = 0;i < n;++i)
    {
        if (a[i] == x) return true;
    }
    return false;
}
signed main()
{
    // 输入输出优化
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    cin >> x >> n;
    for (int i = 0;i < n;++i)
    {
        cin >> a[i];
    }
    int p1 = x, p2 = x;
    while (find(p1)) p1++;
    while (find(p2)) p2--;
    if (p1 - x < x - p2) cout << p1 << endl;
    else cout << p2 << endl;
    return 0;
}
